/*
 * Copyright 2007 Matt Jensen
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */
package org.jtell.internal.config.xml;

import java.util.Set;
import java.util.HashSet;

/**
 * <p>
 * <code>ListenerElement</code> accumulates and holds the information in a <code>&lt;listener ...&gt;</code>
 * configuration element.
 * </p>
 * <p>
 * <strong>Thread Safety</strong><br/>
 * Instances of this class are not safe for multithreaded access.
 * </p>
 */
public class ListenerElement
{
    /**
     * <p>
     * The nested <code>&lt;handler ...&gt;</code> elements. 
     * </p>
     */
    private final Set<HandlerElement> m_handlers = new HashSet<HandlerElement>();

    /**
     * <p>
     * The listener class name.
     * </p>
     */
    private String m_listenerClassName;

    /**
     * <p>
     * Construct a {@link ListenerElement} instance.
     * </p>
     */
    public ListenerElement()
    {
        super();
    }

    public ListenerElement addHandler(final HandlerElement handlerElement)
    {
        m_handlers.add(handlerElement);
        return this;
    }

    public Set<HandlerElement> getHandlers()
    {
        return m_handlers;
    }

    public String getListenerClassName()
    {
        return m_listenerClassName;
    }

    public ListenerElement setListenerClassName(String listenerClassName)
    {
        m_listenerClassName = listenerClassName;
        return this;
    }
}
